# coding=utf-8

#python
import os
import random
import webapp2

#set django version
#os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
#from google.appengine.dist import use_library
#use_library('django', '1.2')

#appengine
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import users
from google.appengine.ext.webapp import template

#lib
from const import *

#handlers
class CreateHandler(webapp.RequestHandler):
    def get(self):
    
        #Collect GEO Headers
        header_country=self.request.headers.get('X-AppEngine-Country', 'BR')
        header_region=self.request.headers.get('X-AppEngine-Region', 'sp')
        header_city=self.request.headers.get('X-AppEngine-City', 'são paulo')
        header_citylatlong=self.request.headers.get('X-AppEngine-CityLatLong', '-23.531693,-46.789923')

        #display error or warnings
        template_values = {
                'nome':'valor',
                'country':header_country,
                'region':header_region,
                'city':header_city,
                'citylatlong':header_citylatlong,
        }
        path = os.path.join(os.path.dirname(__file__), '../templates/create.htm')
        self.response.out.write(template.render(path, template_values))


app = webapp2.WSGIApplication(
                                     [('.*', CreateHandler)],
                                     debug=True)

